#include<stdio.h>
#include<time.h>
#include<random>
#include<unistd.h>
#include<iostream>
#include <string.h>
const int N = 1e9;
 
//快速排序
void my_qsort(int*arr,int left,int right)
{
    if(left>=right)
    {
        return;
    }
    
    int mid = (right+left)/2;
    int key =  arr[mid];
    int i = left,l = left-1,r = right+1;

    while(i<r)
    {
        if(arr[i]<key)
        {
           std:: swap(arr[++l],arr[i++]);
        }
        else if(arr[i] == key)
        {
            i++;
        }
        else
        {
            std::swap(arr[--r],arr[i]);
        }
    }

    my_qsort(arr,left,l),my_qsort(arr,r,right);
}





//分治算法
void my_partsort(int* arr,int left,int right)
{
    if(left>=right) return;

    int mid = (left + right) / 2;

    my_partsort(arr, left, mid);
    my_partsort(arr, mid + 1, right);

    //合并
    int i = 0, l =left,r = mid+1;
    int tmp[right - left + 1];
    while(l<=mid&&r<=right)
    {
        tmp[i++] = arr[l] < arr[r] ? arr[l++] : arr[r++];
    }

    while(r<=right)
    {
        tmp[i++] = arr[r++];
    }

    while(l<=mid)
    {
        tmp[i++] = arr[l++];
    }

    for(int i = left;i<=right;i++)
    {
        arr[i] = tmp[i-left];
    }
}

// 堆排序
void heapify(int *arr, int parent, int n)
{

    int largest = parent;
    int left = 2 * parent + 1;
    int right = 2 * parent + 2;
    if (left < n && arr[left] > arr[largest])
    {
        largest = left;
    }

    if (right < n && arr[right] > arr[largest])
    {
        largest = right;
    }

    if (largest != parent)
    {
        std::swap(arr[parent], arr[largest]);
        // 递归调整
        heapify(arr, largest, n);
    }
}

void heapsort(int *arr, int n)
{
    for (int i = (n - 1) / 2; i >= 0; i--)
    {
        heapify(arr, i, n);
    }

    for (int i = n - 1; i >= 0; i--)
    {
        std::swap(arr[0], arr[i]);
        heapify(arr, 0, i);
    }
}

#include <stdio.h>

long long ack(int m, int n)
{
    if (m == 0)
    {
        return n + 1;
    }
    else if (n == 0)
    {
        return ack(m - 1, 1);
    }
    else
    {
        //printf("m = %d, n = %d\n", m, n);
        return ack(m - 1, ack(m, n - 1));
    }
}

int main()
{
    int m,n;
    scanf("%d%d", &n, &m);
    int ret = ack(n, m);
    printf("%d\n", ret);
    return 0;
}

// int main()
// {
//     int n  = 0;
//     scanf("%d",&n);
//     int arr[n] = {0};
//     srand((unsigned)NULL);
//     for(int i = 0;i<n;i++)
//     {
//         arr[i] =rand()%N;
//         printf("%d ", arr[i]);
//     }

//     printf("\n");
//     printf("\n");
//     clock_t start, end;
//     start = clock();
//    // my_qsort(arr, 0, n-1);
//    // my_partsort(arr, 0, n - 1);
//     heapsort(arr, n);
//     end = clock();
//     for (int i = 0; i < n; i++)
//     {
//         printf("%d ", arr[i]);
//     }
//     printf("\n");
//     printf("运行时间：%ldms\n", end - start);
//     return 0;
// }
